home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77548_ots_table.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  65.3 KB  |  2,592 lines

  1. <%    '==================================================
  2.     ' Module:    ots_table.asp
  3.     '
  4.     ' Synopsis:    Object Task Selector Table Formatting Functions
  5.     '
  6.     ' Copyright (c) Microsoft Corporation.  All rights reserved.
  7.     '================================================== %>
  8. <%
  9.  
  10. '
  11. ' --------------------------------------------------------------
  12. ' T A B L E  O B J E C T
  13. ' --------------------------------------------------------------
  14. '
  15.  
  16.  
  17. Const OTS_TABLE_DIM         = 22
  18. Const OTS_TABLE_OBJECT         = 0
  19. Const OTS_TABLE_TYPE        = 1
  20. Const OTS_TABLE_CAPTION        = 2
  21. Const OTS_TABLE_DESC        = 3
  22. Const OTS_TABLE_COLS        = 4
  23. Const OTS_TABLE_ROWS        = 5
  24. Const OTS_TABLE_ID            = 6
  25. Const OTS_TABLE_TASKS        = 7
  26. Const OTS_TABLE_SORT        = 8
  27. Const OTS_TABLE_TASKS_TITLE    = 9
  28. Const OTS_TABLE_PKEY_NAME = 10
  29. Const OTS_TABLE_MULTI_SELECT = 11
  30. Const OTS_TABLE_AUTO_INIT = 12
  31. Const OTS_TABLE_SEARCHING = 13
  32. Const OTS_TABLE_PAGING = 14
  33. Const OTS_TABLE_PAGE_MAX = 15
  34. Const OTS_TABLE_PAGE_MIN = 16
  35. Const OTS_TABLE_PAGE_CURRENT = 17
  36. Const OTS_TABLE_PAGE_RESET = 18
  37.  
  38. Const OTS_TABLE_SORT_COL = 19
  39. Const OTS_TABLE_SORT_SEQ = 20
  40. Const OTS_TABLE_SORT_SET = 21
  41.  
  42. Const OTS_TABLE_OBJECT_ID     = "Table"    ' Note: DO NOT LOCALIZE
  43. Const OTS_TABLE_TYPE_BASIC     = 1
  44.  
  45.  
  46. DIM OTS_TABLE_NEXT_ID
  47.  
  48. OTS_TABLE_NEXT_ID    = 1
  49.  
  50.  
  51. ' --------------------------------------------------------------
  52. ' Function:    OTS_CreateTable
  53. '
  54. ' Synopsis:    Create a new object task selection object
  55. ' Arguments: [in] Caption for the table
  56. '            [in] Description of what the table contains
  57. '
  58. ' Returns:    The Table object
  59. '
  60. ' --------------------------------------------------------------
  61. Public Function OTS_CreateTable(ByVal TableCaption, ByVal TableDescription)
  62.     Dim Table()
  63.     ReDim Table(OTS_TABLE_DIM)
  64.  
  65.     SA_ClearError()
  66.     
  67.     Table(OTS_TABLE_OBJECT) = OTS_TABLE_OBJECT_ID
  68.     Table(OTS_TABLE_TYPE) = OTS_TABLE_TYPE_BASIC
  69.     Table(OTS_TABLE_CAPTION) = TableCaption
  70.     Table(OTS_TABLE_DESC) = TableDescription
  71.     Table(OTS_TABLE_COLS) = Null
  72.     Table(OTS_TABLE_PKEY_NAME) = "PKey"
  73.     Table(OTS_TABLE_MULTI_SELECT) = FALSE
  74.     Table(OTS_TABLE_AUTO_INIT) = TRUE
  75.     Table(OTS_TABLE_SEARCHING) = FALSE
  76.     
  77.     Table(OTS_TABLE_PAGING) = FALSE
  78.     Table(OTS_TABLE_PAGE_MAX) = 0
  79.     Table(OTS_TABLE_PAGE_MIN) = 1
  80.     Table(OTS_TABLE_PAGE_CURRENT) = 1
  81.     Table(OTS_TABLE_PAGE_RESET) = FALSE
  82.     Table(OTS_TABLE_SORT_COL) = 0
  83.     Table(OTS_TABLE_SORT_SEQ) = "A"
  84.     Table(OTS_TABLE_SORT_SET) = FALSE
  85.     OTS_CreateTable = Table
  86.  
  87. End Function
  88.  
  89.  
  90. ' --------------------------------------------------------------
  91. ' Function:    OTS_IsValidTable
  92. '
  93. ' Synopsis:    Verify that the reference object is a valid table. To
  94. '            be valid it must be an array, of the correct size,
  95. '            which has OTS_TABLE_OBJECT_ID as the first element
  96. '
  97. '            Note: This is the only function in this package
  98. '            that DOES NOT RETURN FAILURE CODES. If
  99. '            the table is valid it returns true. Otherwise
  100. '            it returns false.
  101. '
  102. ' Returns:    True if the table is valid, otherwise false
  103. ' --------------------------------------------------------------
  104. Private Function OTS_IsValidTable(ByRef Table)
  105.     Dim bisValidTable
  106.     bisValidTable = false
  107.     
  108.     If (IsArray(Table)) Then
  109.         If ( UBound(Table) >= OTS_TABLE_DIM ) Then
  110.             Dim tableObject
  111.             tableObject = Table(OTS_TABLE_OBJECT)
  112.             If (tableObject = OTS_TABLE_OBJECT_ID) Then
  113.                 bisValidTable = true
  114.             Else
  115.                 SA_TraceOut "OTS_IsValidTable", "(tableObject <> OTS_TABLE_OBJECT_ID)"
  116.             End If
  117.         Else
  118.             SA_TraceOut "OTS_IsValidTable", "(UBound(Table) >= OTS_TABLE_DIM)"
  119.         End If
  120.     Else
  121.         SA_TraceOut "OTS_IsValidTable", "(IsArray(Table))"
  122.     End If
  123.     OTS_IsValidTable = bisValidTable
  124. End Function
  125.  
  126.  
  127. ' --------------------------------------------------------------
  128. ' Function:    OTS_IsAutoInitEnabled
  129. '
  130. ' Synopsis:    Check and return the state of the auto initialization
  131. '            option. 
  132. ' Arguments: [in] Table
  133. '
  134. ' Return    gc_ERR_SUCCESS or error code
  135. '
  136. ' --------------------------------------------------------------
  137. Public Function OTS_IsAutoInitEnabled(ByRef Table)
  138.     Dim rc
  139.     OTS_IsAutoInitEnabled = FALSE
  140.     
  141.     SA_ClearError()
  142.     If (OTS_IsValidTable(Table)) Then
  143.         OTS_IsAutoInitEnabled = Table(OTS_TABLE_AUTO_INIT)
  144.     Else
  145.         Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsAutoInitEnabled")
  146.     End If
  147.  
  148. End Function
  149.  
  150.  
  151. ' --------------------------------------------------------------
  152. ' Function:    OTS_EnableAutoInit
  153. '
  154. ' Synopsis:    Toggle the auto initialization option. 
  155. ' Arguments: [in] Table
  156. '            [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  157. '
  158. ' Return    gc_ERR_SUCCESS or error code
  159. '
  160. ' --------------------------------------------------------------
  161. Public Function OTS_EnableAutoInit(ByRef Table, ByVal bEnable)
  162.     Dim rc
  163.     OTS_EnableAutoInit = gc_ERR_SUCCESS
  164.     
  165.     SA_ClearError()
  166.     If (OTS_IsValidTable(Table)) Then
  167.         Table(OTS_TABLE_AUTO_INIT) = bEnable
  168.     Else
  169.         OTS_EnableAutoInit = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableAutoInit")
  170.     End If
  171.  
  172. End Function
  173.  
  174.  
  175. ' --------------------------------------------------------------
  176. ' Function:    OTS_IsSearchEnabled
  177. '
  178. ' Synopsis:    Check and return the state of the searching option
  179. ' Arguments: [in] Table
  180. '
  181. ' Return    gc_ERR_SUCCESS or error code
  182. '
  183. ' --------------------------------------------------------------
  184. Public Function OTS_IsSearchEnabled(ByRef Table)
  185.     Dim rc
  186.     OTS_IsSearchEnabled = FALSE
  187.     
  188.     SA_ClearError()
  189.     If (OTS_IsValidTable(Table)) Then
  190.         Dim aColAttributes
  191.         Dim colCount
  192.         
  193.         If ( 0 = OTS_GetColumnAttributes(Table, aColAttributes)) Then
  194.             For colCount = 0 to UBound(aColAttributes)-1
  195.                 If (aColAttributes(colCount) AND OTS_COL_SEARCH) Then
  196.                     OTS_IsSearchEnabled = TRUE
  197.                 End If
  198.             Next
  199.         End If
  200.     Else
  201.         Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsSearchEnabled")
  202.     End If
  203.  
  204. End Function
  205.  
  206.  
  207.  
  208. ' --------------------------------------------------------------
  209. ' Function:    OTS_EnableSearch
  210. '
  211. ' Synopsis:    Toggle the search capability
  212. ' Arguments: [in] Table
  213. '            [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  214. '
  215. ' Return    gc_ERR_SUCCESS or error code
  216. '
  217. ' --------------------------------------------------------------
  218. 'Public Function OTS_EnableSearch(ByRef Table, ByVal bEnable)
  219. '    Dim rc
  220. '    OTS_EnableSearch = gc_ERR_SUCCESS
  221. '    
  222. '    SA_ClearError()
  223. '    If (OTS_IsValidTable(Table)) Then
  224. '        Table(OTS_TABLE_SEARCHING) = bEnable
  225. '    Else
  226. '        OTS_EnableSearch = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableSearch")
  227. '    End If
  228. '
  229. 'End Function
  230.  
  231.  
  232. ' --------------------------------------------------------------
  233. ' Function:    OTS_IsPagingEnabled
  234. '
  235. ' Synopsis:    Check and return the state of the paging option
  236. ' Arguments: [in] Table
  237. '
  238. ' Return    gc_ERR_SUCCESS or error code
  239. '
  240. ' --------------------------------------------------------------
  241. Public Function OTS_IsPagingEnabled(ByRef Table)
  242.     Dim rc
  243.     OTS_IsPagingEnabled = FALSE
  244.     
  245.     SA_ClearError()
  246.     If (OTS_IsValidTable(Table)) Then
  247.         OTS_IsPagingEnabled = Table(OTS_TABLE_PAGING)
  248.     Else
  249.         Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsPagingEnabled")
  250.     End If
  251.  
  252. End Function
  253.  
  254.  
  255.  
  256. ' --------------------------------------------------------------
  257. ' Function:    OTS_EnablePaging
  258. '
  259. ' Synopsis:    Toggle the paging capability
  260. ' Arguments: [in] Table
  261. '            [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  262. '
  263. ' Return    gc_ERR_SUCCESS or error code
  264. '
  265. ' --------------------------------------------------------------
  266. Public Function OTS_EnablePaging(ByRef Table, ByVal bEnable)
  267.     Dim rc
  268.     OTS_EnablePaging = gc_ERR_SUCCESS
  269.     
  270.     SA_ClearError()
  271.     If (OTS_IsValidTable(Table)) Then
  272.         Table(OTS_TABLE_PAGING) = bEnable
  273.         Table(OTS_TABLE_PAGE_MAX) = -1
  274.         Table(OTS_TABLE_PAGE_MIN) = 1
  275.         Table(OTS_TABLE_PAGE_CURRENT) = 1
  276.     Else
  277.         OTS_EnablePaging = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnablePaging")
  278.     End If
  279.  
  280. End Function
  281.  
  282. Public Function OTS_SetPagingRange(ByRef Table, ByVal iMin, ByVal iMax, ByVal iCurrent)
  283.     Dim rc
  284.     OTS_SetPagingRange = gc_ERR_SUCCESS
  285.     
  286.     SA_ClearError()
  287.     If (OTS_IsValidTable(Table)) Then
  288.         Table(OTS_TABLE_PAGE_RESET) = TRUE
  289.         Table(OTS_TABLE_PAGE_MAX) = iMax
  290.         Table(OTS_TABLE_PAGE_MIN) = iMin
  291.         Table(OTS_TABLE_PAGE_CURRENT) = iCurrent
  292.     Else
  293.         OTS_SetPagingRange = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetPagingRange")
  294.     End If
  295.  
  296. End Function
  297.  
  298. Private Function OTS_IsPagingReset(ByRef Table)
  299.     Dim rc
  300.     OTS_IsPagingReset = FALSE
  301.     
  302.     SA_ClearError()
  303.     If (OTS_IsValidTable(Table)) Then
  304.         OTS_IsPagingReset = Table(OTS_TABLE_PAGE_RESET)
  305.     Else
  306.         Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsPagingReset")
  307.     End If
  308.  
  309. End Function
  310.  
  311.  
  312. Public Function OTS_GetPagingRange(ByRef Table, ByRef bEnabled, ByRef iPageMin, ByRef iPageMax, ByRef iPageCurrent)
  313.     
  314.     If ( OTS_IsPagingEnabled(Table) ) Then
  315.         bEnabled = TRUE
  316.  
  317.         If ( Len(Trim(Request.QueryString(FLD_PagingPageCurrent))) > 0 ) Then
  318.             iPageMin = CInt(SA_GetParam(FLD_PagingPageMin))
  319.             iPageMax = CInt(SA_GetParam(FLD_PagingPageMax))
  320.             iPageCurrent = CInt(SA_GetParam(FLD_PagingPageCurrent))
  321.         Else
  322.         
  323.             If ( OTS_IsPagingReset(Table) ) Then
  324.                 iPageMax = CInt(Table(OTS_TABLE_PAGE_MAX))
  325.                 iPageMin = CInt(Table(OTS_TABLE_PAGE_MIN))
  326.                 iPageCurrent = CInt(Table(OTS_TABLE_PAGE_CURRENT))
  327.             Else
  328.                 iPageMin = CInt(SA_GetParam(FLD_PagingPageMin))
  329.                 iPageMax = CInt(SA_GetParam(FLD_PagingPageMax))
  330.                 iPageCurrent = CInt(SA_GetParam(FLD_PagingPageCurrent))
  331.             End If
  332.         End If
  333.         
  334.     Else
  335.         bEnabled = FALSE
  336.         iPageMin = 1
  337.         iPageMax = 0
  338.         iPageCurrent = 1
  339.     End If
  340. End Function
  341.  
  342.  
  343. ' --------------------------------------------------------------
  344. ' Function:    OTS_SetTableTasksTitle
  345. '
  346. ' Synopsis:    Set the tasks title
  347. ' Arguments: [in] Table
  348. '            [in] Title
  349. '
  350. ' Return    gc_ERR_SUCCESS or error code
  351. '
  352. ' --------------------------------------------------------------
  353. Public Function OTS_SetTableTasksTitle(ByRef Table, ByVal TasksTitle)
  354.     Dim rc
  355.     rc = gc_ERR_SUCCESS
  356.     
  357.     SA_ClearError()
  358.     If (OTS_IsValidTable(Table)) Then
  359.         Table(OTS_TABLE_TASKS_TITLE) = TasksTitle
  360.     Else
  361.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableTasksTitle")
  362.     End If
  363.  
  364.     OTS_SetTableTasksTitle = rc
  365. End Function
  366.  
  367. ' --------------------------------------------------------------
  368. ' Function:    OTS_GetTableTasksTitle
  369. '
  370. ' Synopsis:    Get the tasks title
  371. ' Arguments: [in] Table
  372. '
  373. ' Return    gc_ERR_SUCCESS or error code
  374. '
  375. ' --------------------------------------------------------------
  376. Public Function OTS_GetTableTasksTitle(ByRef Table, ByRef tasksTitle)
  377.     Dim rc
  378.     rc = gc_ERR_SUCCESS
  379.     
  380.     SA_ClearError()
  381.     If (OTS_IsValidTable(Table)) Then
  382.         tasksTitle = Table(OTS_TABLE_TASKS_TITLE)
  383.     Else
  384.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableTasksTitle")
  385.     End If
  386.  
  387.     OTS_GetTableTasksTitle = rc
  388. End Function
  389.  
  390.  
  391. ' --------------------------------------------------------------
  392. ' Function:    OTS_SetTableMultiSelection
  393. '
  394. ' Synopsis:    Enable OTS table multi selection capability.
  395. ' Arguments: [in] Table
  396. '            [in] bEnableMultiSelect set to TRUE to enable, FALSE to disable
  397. '
  398. ' Return    gc_ERR_SUCCESS or error code
  399. '
  400. ' History:    Added SAK 2.0
  401. '
  402. ' --------------------------------------------------------------
  403. Public Function OTS_SetTableMultiSelection(ByRef Table, ByVal bEnableMultiSelect)
  404.     SA_ClearError()
  405.     OTS_SetTableMultiSelection =  gc_ERR_SUCCESS
  406.     
  407.     If (OTS_IsValidTable(Table)) Then
  408.         Call SA_TraceOut("OTS_TABLE", "Setting multi selection to " + CStr(bEnableMultiSelect))
  409.         Table(OTS_TABLE_MULTI_SELECT) = bEnableMultiSelect
  410.     Else
  411.         OTS_SetTableMultiSelection =  SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableMultiSelection")
  412.     End If
  413. End Function
  414.  
  415.  
  416. ' --------------------------------------------------------------
  417. ' Function:    OTS_IsTableMultiSelection
  418. '
  419. ' Synopsis:    Check to see if multi selection is enabled.
  420. ' Arguments: [in] Table
  421. '
  422. ' Return    TRUE if multi selection is enabled, otherwise false
  423. '
  424. ' History:    Added SAK 2.0
  425. '
  426. ' --------------------------------------------------------------
  427. Public Function OTS_IsTableMultiSelection(ByRef Table)
  428.     SA_ClearError()
  429.     OTS_IsTableMultiSelection = FALSE
  430.     
  431.     If (OTS_IsValidTable(Table)) Then
  432.         OTS_IsTableMultiSelection = Table(OTS_TABLE_MULTI_SELECT)
  433.     Else
  434.         Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableMultiSelection")
  435.     End If
  436. End Function
  437.  
  438.  
  439. ' --------------------------------------------------------------
  440. ' Function:    OTS_EnableTableSort
  441. '            DEPRECATED in SAK 2.0 Replaced with OTS_SortTable
  442. '
  443. ' Synopsis:    Enable table sorting. If sorting is enabled it is performed
  444. '            inside ServeTable before the table is rendered. 
  445. '    
  446. ' Arguments: [in] Table
  447. '            [in] EnableSort true to sort, false to not sort
  448. '
  449. ' Return    gc_ERR_SUCCESS or error code
  450. '
  451. ' --------------------------------------------------------------
  452. Public Function OTS_EnableTableSort(ByRef Table, ByVal EnableSort)
  453.     Dim rc
  454.     rc = gc_ERR_SUCCESS
  455.     
  456.     SA_ClearError()
  457.     If (OTS_IsValidTable(Table)) Then
  458.         Table(OTS_TABLE_SORT) = EnableSort
  459.     Else
  460.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableTableSort")
  461.     End If
  462.  
  463.     OTS_EnableTableSort = rc
  464. End Function
  465.  
  466.  
  467. ' ---------------------------------------------------------------------------
  468. ' Function:    OTS_SetTableSortCriteria
  469. '
  470. ' Synopsis:    Set the advanced sorting options for the OTS table. If the table is sorted
  471. '            externally, this API can be used to indicated the current sort column and 
  472. '            sort sequence, which is indicated visually in the UI by display of a sort
  473. '            sequence image in the current sort column. It's unnecessary to call this
  474. '            API if the table is sorted using OTS_SortTable.
  475. ' Arguments: [in] Table
  476. '            [in] sortCol    Index number of current sort column
  477. '            [in] sortSeq    Sort sequence, "A" for ascending, "D" for descending
  478. '
  479. ' Return    gc_ERR_SUCCESS or error code
  480. '
  481. ' --------------------------------------------------------------
  482. Public Function OTS_SetTableSortCriteria(ByRef Table, ByVal sortCol, ByVal sortSeq)
  483.     Dim rc
  484.     rc = gc_ERR_SUCCESS
  485.     
  486.     SA_ClearError()
  487.     If (OTS_IsValidTable(Table)) Then
  488.         Table(OTS_TABLE_SORT_COL) = sortCol
  489.         Table(OTS_TABLE_SORT_SEQ) = sortSeq
  490.         Table(OTS_TABLE_SORT_SET) = TRUE
  491.     Else
  492.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableSortCriteria")
  493.     End If
  494.  
  495.     OTS_SetTableSortCriteria = rc
  496. End Function
  497.     
  498.  
  499. Private Function OTS_IsColumnSortEnabled(ByRef Table)
  500.     Dim rc
  501.     rc = gc_ERR_SUCCESS
  502.     
  503.     SA_ClearError()
  504.     If (OTS_IsValidTable(Table)) Then
  505.         rc = Table(OTS_TABLE_SORT_SET)
  506.     Else
  507.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsColumnSortEnabled")
  508.     End If
  509.  
  510.     OTS_IsColumnSortEnabled = rc
  511. End Function
  512.  
  513. Private Function OTS_GetTableSortSequence(ByRef Table, ByRef sortSequence)
  514.     Dim rc
  515.     rc = gc_ERR_SUCCESS
  516.     
  517.     SA_ClearError()
  518.     If (OTS_IsValidTable(Table)) Then
  519.     
  520.         sortSequence = SA_GetParam(FLD_SortingSequence)
  521.         
  522.         If ( Len(Trim(sortSequence)) <= 0 ) Then
  523.             sortSequence = Table(OTS_TABLE_SORT_SEQ)
  524.         End If
  525.     
  526.     Else
  527.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSortSequence")
  528.     End If
  529.  
  530.     OTS_GetTableSortSequence = rc
  531. End Function
  532.     
  533.  
  534. ' --------------------------------------------------------------
  535. ' Function:    OTS_GetTableSortColumn
  536. '
  537. ' Synopsis:    Get the sort column number
  538. ' Arguments: [in] Table
  539. '            [out] sortCol zero (0) based index of soft column
  540. '
  541. ' Return    gc_ERR_SUCCESS or error code
  542. '
  543. ' --------------------------------------------------------------
  544. Private Function OTS_GetTableSortColumn(ByRef Table, ByRef sortCol)
  545.     Dim columns
  546.     Dim col
  547.     Dim rc
  548.     rc = gc_ERR_SUCCESS
  549.  
  550.     SA_ClearError()
  551.     If (OTS_IsValidTable(Table)) Then
  552.  
  553.         '
  554.         ' If SAK 2.0
  555.         If ( SA_GetVersion() >=  gc_V2 ) Then
  556.  
  557.             '
  558.             ' Use the current sort column parameter if available
  559.             sortCol = SA_GetParam(FLD_SortingColumn)
  560.             If ( Len(Trim(sortCol)) > 0 ) Then
  561.                 sortCol = CInt(sortCol)
  562.                 OTS_GetTableSortColumn = rc
  563.                 Exit Function
  564.             '
  565.             ' Else if the sort criteria was set then use it
  566.             ElseIf ( TRUE = Table(OTS_TABLE_SORT_SET) ) Then
  567.                 sortCol = Table(OTS_TABLE_SORT_COL)
  568.                 OTS_GetTableSortColumn = rc
  569.                 Exit Function
  570.             '
  571.             ' Otherwise drop through and use SAK 1.x logic
  572.             Else
  573.             
  574.             End If
  575.             
  576.         End If
  577.  
  578.     
  579.         If (IsArray(Table(OTS_TABLE_COLS))) Then
  580.             Dim colCount
  581.             Dim count
  582.             Dim found
  583.  
  584.             found = false
  585.             columns = Table(OTS_TABLE_COLS)
  586.             colCount = UBound(columns)
  587.             For count = 0 to colCount-1
  588.                 Dim bIsColSort
  589.  
  590.                 rc = OTS_IsColumnSort(columns(count), bIsColSort)
  591.                 If ( rc <> gc_ERR_SUCCESS) Then
  592.                     OTS_GetTableSortColumn = rc
  593.                     Exit Function
  594.                 End If
  595.                 
  596.                 If (bIsColSort) Then
  597.                     sortCol = count
  598.                     found = true
  599.                     count = colCount+1
  600.                 End If
  601.             Next
  602.  
  603.             If (NOT found) Then
  604.                 sortCol = 0
  605.             End If
  606.  
  607.         Else
  608.             rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, "OTS_GetTableSortColumn")
  609.         End If
  610.     Else
  611.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSortColumn")
  612.     End If
  613.     
  614.     OTS_GetTableSortColumn = rc
  615. End Function
  616.  
  617.  
  618. ' --------------------------------------------------------------
  619. ' Function:    OTS_IsTableSortEnabled
  620. '
  621. ' Synopsis:    Check to see if table sorting is enabled
  622. ' Arguments: [in] Table
  623. '            [out] bIsSortEnabledOut set with value of sort enabled flag
  624. '
  625. ' Return    gc_ERR_SUCCESS or error code
  626. '
  627. ' --------------------------------------------------------------
  628. Public Function OTS_IsTableSortEnabled(ByRef Table, ByRef bIsSortEnabledOut)
  629.     Dim rc
  630.     rc = gc_ERR_SUCCESS
  631.     
  632.     SA_ClearError()
  633.     If (OTS_IsValidTable(Table)) Then
  634.         bIsSortEnabledOut = Table(OTS_TABLE_SORT)
  635.     Else
  636.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableSortEnabled")
  637.     End If
  638.  
  639.     OTS_IsTableSortEnabled = rc    
  640. End Function
  641.  
  642.  
  643. ' --------------------------------------------------------------
  644. ' Function:    OTS_AddTableTask
  645. '
  646. ' Synopsis:    Add a Task to the table
  647. ' Arguments: [in] Table
  648. '            [in] Task to be added to the table. Task must have been
  649. '                created with the CreateTask API.
  650. '
  651. ' Return    gc_ERR_SUCCESS or error code
  652. '
  653. ' --------------------------------------------------------------
  654. Public Function OTS_AddTableTask(ByRef Table, ByRef Task)
  655.     Dim rc
  656.     rc = gc_ERR_SUCCESS
  657.     
  658.     SA_ClearError()
  659.     If (OTS_IsValidTable(Table)) Then
  660.         If (OTS_IsValidTask(Task)) Then
  661.     
  662.             Dim tasks
  663.             Dim currentTasks
  664.             Dim taskCount
  665.  
  666.             '
  667.             ' Get the array
  668.             '
  669.             currentTasks = Table(OTS_TABLE_TASKS)
  670.  
  671.             If IsArray(currentTasks) Then
  672.                 '
  673.                 ' Resize the array
  674.                 '
  675.                 tasks = currentTasks
  676.                 taskCount = UBOUND(tasks)
  677.                 taskCount = taskCount + 1
  678.                 ReDim Preserve tasks(taskCount)
  679.             Else
  680.                 '
  681.                 ' Create the array
  682.                 '
  683.                 taskCount = 1
  684.                 ReDim tasks(taskCount)
  685.             End If
  686.  
  687.             '
  688.             ' Store the new task
  689.             '
  690.             tasks(taskCount-1) = Task
  691.  
  692.             '
  693.             ' Update the OTS_TABLE_TASKS
  694.             '
  695.             Table(OTS_TABLE_TASKS) = tasks
  696.         Else
  697.             rc = SA_SetLastError(OTS_ERR_INVALID_TASK, "OTS_AddTableTask")
  698.         End If
  699.     Else
  700.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableTask")
  701.     End If
  702.  
  703.     OTS_AddTableTask = rc
  704.     
  705. End Function
  706.  
  707.  
  708. ' --------------------------------------------------------------
  709. ' Function:    OTS_AddTableColumn
  710. '
  711. ' Synopsis:    Add a column to the table
  712. ' Arguments: [in] Table
  713. '            [in] Column to be added to the table
  714. '
  715. ' Return    gc_ERR_SUCCESS or error code
  716. '
  717. ' --------------------------------------------------------------
  718. Public Function OTS_AddTableColumn(ByRef Table, ByRef Column)
  719.     Dim rc
  720.     rc = gc_ERR_SUCCESS
  721.  
  722.     SA_ClearError()
  723.     If (OTS_IsValidTable(Table)) Then
  724.         If (OTS_IsValidColumn(Column)) Then
  725.             Dim cols
  726.             Dim currentCols
  727.             Dim colCount
  728.  
  729.             '
  730.             ' Get the current column array
  731.             '
  732.             currentCols = Table(OTS_TABLE_COLS)
  733.  
  734.             If IsArray(currentCols) Then
  735.                 '
  736.                 ' Resize the existing cols array
  737.                 '
  738.                 cols = currentCols
  739.                 colCount = UBOUND(cols)
  740.                 colCount = colCount + 1
  741.                 ReDim Preserve cols(colCount)
  742.             Else
  743.                 '
  744.                 ' Create the cols array
  745.                 '
  746.                 colCount = 1
  747.                 ReDim cols(colCount)
  748.             End If
  749.  
  750.             '
  751.             ' Store the new column
  752.             '
  753.             cols(colCount-1) = Column
  754.     
  755.             '
  756.             ' Update the OTS_TABLE_COLS
  757.             '
  758.             Table(OTS_TABLE_COLS) = cols
  759.         Else
  760.             rc = SA_SetLastError(OTS_ERR_INVALID_COLUMN, "OTS_AddTableColumn")
  761.         End If
  762.  
  763.     Else
  764.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableColumn")
  765.     End If
  766.     
  767.     OTS_AddTableColumn = rc
  768.     
  769. End Function
  770.  
  771.  
  772. ' --------------------------------------------------------------
  773. ' Function:    OTS_AddTableRow
  774. '
  775. ' Synopsis:    Add a row to the table
  776. ' Arguments: [in] Table
  777. '            [in] RowIn row array to be added to the table, 
  778. '                must be an array type.
  779. '
  780. ' Return    gc_ERR_SUCCESS or error code
  781. '
  782. ' --------------------------------------------------------------
  783. Public Function OTS_AddTableRow(ByRef Table, ByRef RowIn)
  784.     Dim rows
  785.     Dim currentRows
  786.     Dim rowCount
  787.     Dim rc
  788.     rc = gc_ERR_SUCCESS
  789.  
  790.     SA_ClearError()
  791.     If (OTS_IsValidTable(Table)) Then
  792.         If (IsArray(RowIn)) Then
  793.             '
  794.             ' Get the current rows array
  795.             '
  796.             currentRows = Table(OTS_TABLE_ROWS)
  797.  
  798.             If IsArray(currentRows) Then
  799.                 '
  800.                 ' Resize the existing array
  801.                 '
  802.                 rows = currentRows
  803.                 rowCount = UBOUND(rows)
  804.                 rowCount = rowCount + 1
  805.                 ReDim Preserve rows(rowCount)
  806.             Else
  807.                 '
  808.                 ' Create the array
  809.                 '
  810.                 rowCount = 1
  811.                 ReDim rows(rowCount)
  812.             End If
  813.     
  814.             '
  815.             ' Store the new row
  816.             '
  817.             rows(rowCount-1) = RowIn
  818.  
  819.             '
  820.             ' Update the OTS_TABLE_COLS
  821.             '
  822.             Table(OTS_TABLE_ROWS) = rows
  823.         Else
  824.             rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, "OTS_AddTableRow")
  825.         End If
  826.     Else
  827.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableRow")
  828.     End If
  829.  
  830.     OTS_AddTableRow = rc
  831. End Function
  832.  
  833.  
  834. ' --------------------------------------------------------------
  835. ' Function:    OTS_SetTableRow
  836. '
  837. ' Synopsis:    Set a row to the table
  838. ' Arguments: [in] Table
  839. '            [in] RowIn row array to be set in the table, 
  840. '                must be an array type.
  841. '            [in] RowNumber zero (0) based index of the row to
  842. '                be set.
  843. '
  844. ' Return    gc_ERR_SUCCESS or error code
  845. '
  846. ' --------------------------------------------------------------
  847. Public Function OTS_SetTableRow(ByRef Table, ByVal RowNumber, ByRef RowIn)
  848.     Dim rc
  849.     rc = gc_ERR_SUCCESS
  850.  
  851.     SA_ClearError()
  852.     If (OTS_IsValidTable(Table)) Then
  853.         '
  854.         ' If the rows have not been presized, do it now
  855.         '
  856.         If (NOT IsArray(Table(OTS_TABLE_ROWS))) Then
  857.             rc = OTS_SetTableRowCount(Table, RowNumber+1)
  858.         End If
  859.         
  860.         '
  861.         ' Grow the rows array if necessary
  862.         '
  863.         If (UBound(Table(OTS_TABLE_ROWS)) <= RowNumber) Then
  864.             rc = OTS_SetTableRowCount(Table, RowNumber+1 )
  865.         End If
  866.  
  867.         '
  868.         ' Row data must be Array type
  869.         '
  870.         If (IsArray(RowIn) ) Then
  871.             Table(OTS_TABLE_ROWS)(RowNumber) = RowIn
  872.         Else
  873.             rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, "OTS_SetTableRow")
  874.         End If
  875.     Else
  876.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRow")
  877.     End If
  878.  
  879.     OTS_SetTableRow = rc
  880. End Function
  881.  
  882.  
  883. ' --------------------------------------------------------------
  884. ' Function:    OTS_SetTableRowCount
  885. '
  886. ' Synopsis:    Set the number of rows in the table. This function can
  887. '            be used to initialize the size of the rows array or to
  888. '            grow or shrink the size of the rows array. Previous
  889. '            contents of the rows array are preserved.
  890. ' Arguments: [in] Table
  891. '            [in] RowCount
  892. '
  893. ' Return    gc_ERR_SUCCESS or error code
  894. '
  895. ' --------------------------------------------------------------
  896. Public Function OTS_SetTableRowCount(ByRef Table, ByVal RowCount)
  897.     Dim rows
  898.     Dim rc
  899.     rc = gc_ERR_SUCCESS
  900.  
  901.     SA_ClearError()
  902.     If (OTS_IsValidTable(Table)) Then
  903.         If (IsArray(Table(OTS_TABLE_ROWS))) Then
  904.             '
  905.             ' Resize the existing rows array
  906.             '
  907.             rows = Table(OTS_TABLE_ROWS)
  908.             ReDim Preserve rows(rowCount)
  909.             Table(OTS_TABLE_ROWS) = rows
  910.         Else
  911.             '
  912.             ' Create the rows array
  913.             '
  914.             ReDim rows(rowCount)
  915.             Table(OTS_TABLE_ROWS) = rows
  916.         End If
  917.     Else
  918.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRowCount")
  919.     End If
  920.     
  921.     OTS_SetTableRowCount = rc
  922.     
  923. End Function
  924.  
  925. ' --------------------------------------------------------------
  926. ' Function:    OTS_GetTablePKeyName
  927. '
  928. ' Synopsis:    Get the name of the PKey query string
  929. ' Arguments: [in] Table
  930. '            [out] PKeyName
  931. '
  932. ' Return    gc_ERR_SUCCESS or error code
  933. '
  934. ' --------------------------------------------------------------
  935. Private Function OTS_GetTablePKeyName(ByRef Table, ByRef pKeyName)
  936.     Dim rc
  937.     rc = gc_ERR_SUCCESS
  938.  
  939.     SA_ClearError()
  940.     If (OTS_IsValidTable(Table)) Then
  941.         pKeyName = Table(OTS_TABLE_PKEY_NAME)
  942.     Else
  943.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTablePKeyName")
  944.     End If
  945.     
  946.     OTS_GetTablePKeyName = rc
  947. End Function
  948.  
  949. ' --------------------------------------------------------------
  950. ' Function:    OTS_SetTablePKeyName
  951. '
  952. ' Synopsis:    Set the name of the PKey query string
  953. ' Arguments: [in] Table
  954. '            [in] PKeyName
  955. '
  956. ' Return    gc_ERR_SUCCESS or error code
  957. '
  958. ' --------------------------------------------------------------
  959. Private Function OTS_SetTablePKeyName(ByRef Table, ByVal pKeyName)
  960.     Dim rc
  961.     rc = gc_ERR_SUCCESS
  962.  
  963.     SA_ClearError()
  964.     If (OTS_IsValidTable(Table)) Then
  965.         Table(OTS_TABLE_PKEY_NAME) = pKeyName
  966.     Else
  967.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTablePKeyName")
  968.     End If
  969.     
  970.     OTS_SetTablePKeyName = rc
  971. End Function
  972.  
  973.  
  974.  
  975. ' --------------------------------------------------------------
  976. ' Function:    OTS_GetKeyColumnForTable
  977. '
  978. ' Synopsis:    Get the key column number
  979. ' Arguments: [in] Table
  980. '            [out] keyCol zero (0) based index of key column
  981. '
  982. ' Return    gc_ERR_SUCCESS or error code
  983. '
  984. ' --------------------------------------------------------------
  985. Private Function OTS_GetKeyColumnForTable(ByRef Table, ByRef keyCol)
  986.     Dim columns
  987.     Dim col
  988.     Dim rc
  989.     rc = gc_ERR_SUCCESS
  990.  
  991.     SA_ClearError()
  992.     If (OTS_IsValidTable(Table)) Then
  993.         If (IsArray(Table(OTS_TABLE_COLS))) Then
  994.             Dim colCount
  995.             Dim count
  996.             Dim found
  997.  
  998.             found = false
  999.             columns = Table(OTS_TABLE_COLS)
  1000.             colCount = UBound(columns)
  1001.             For count = 0 to colCount-1
  1002.                 Dim bIsColKey
  1003.  
  1004.                 rc = OTS_IsColumnKey(columns(count), bIsColKey)
  1005.                 If ( rc <> gc_ERR_SUCCESS) Then
  1006.                     OTS_GetKeyColumnForTable = rc
  1007.                     Exit Function
  1008.                 End If
  1009.                 
  1010.                 If (bIsColKey) Then
  1011.                     keyCol = count
  1012.                     found = true
  1013.                     count = colCount+1
  1014.                 End If
  1015.             Next
  1016.  
  1017.             If (NOT found) Then
  1018.                 keyCol = 0
  1019.             End If
  1020.  
  1021.         Else
  1022.             rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, "OTS_GetKeyColumnForTable")
  1023.         End If
  1024.     Else
  1025.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetKeyColumnForTable")
  1026.     End If
  1027.     
  1028.     OTS_GetKeyColumnForTable = rc
  1029. End Function
  1030.  
  1031.  
  1032. ' --------------------------------------------------------------
  1033. ' Function:    OTS_SetTableRows
  1034. '
  1035. ' Synopsis:    Set all rows for the table
  1036. ' Arguments: [in] Table
  1037. '            [in] RowsIn Two dimensional array of table rows
  1038. '
  1039. ' Returns:    gc_ERR_SUCCESS if rows returned
  1040. '            OTS_ERR_NO_ROWS if no rows exist
  1041. '            OTS_ERR_INVALID_TABLE if the table is invalid
  1042. '
  1043. ' --------------------------------------------------------------
  1044. Private Function OTS_SetTableRows(ByRef Table, ByRef RowsIn)
  1045.     Dim rc
  1046.     rc = gc_ERR_SUCCESS
  1047.  
  1048.     SA_ClearError()
  1049.     If (OTS_IsValidTable(Table)) Then
  1050.         If ( IsArray( RowsIn ) ) Then
  1051.             Table(OTS_TABLE_ROWS) = RowsIn
  1052.         Else
  1053.             rc = OTS_ERR_NO_ROWS
  1054.         End If
  1055.     Else
  1056.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRows")
  1057.     End If
  1058.  
  1059.     OTS_SetTableRows = rc
  1060. End Function
  1061.  
  1062.  
  1063. ' --------------------------------------------------------------
  1064. ' Function:    OTS_GetTableRows
  1065. '
  1066. ' Synopsis:    Get all rows for the table
  1067. ' Arguments: [in] Table
  1068. '            [out] RowsOut Two dimensional array of table rows
  1069. '
  1070. ' Returns:    gc_ERR_SUCCESS if rows returned
  1071. '            OTS_ERR_NO_ROWS if no rows exist
  1072. '            OTS_ERR_INVALID_TABLE if the table is invalid
  1073. '
  1074. ' --------------------------------------------------------------
  1075. Private Function OTS_GetTableRows(ByRef Table, ByRef RowsOut)
  1076.     Dim rc
  1077.     rc = gc_ERR_SUCCESS
  1078.  
  1079.     SA_ClearError()
  1080.     If (OTS_IsValidTable(Table)) Then
  1081.         If ( IsArray( Table(OTS_TABLE_ROWS)) ) Then
  1082.             RowsOut = Table(OTS_TABLE_ROWS)
  1083.         Else
  1084.             rc = OTS_ERR_NO_ROWS
  1085.         End If
  1086.     Else
  1087.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableRows")
  1088.     End If
  1089.  
  1090.     OTS_GetTableRows = rc
  1091. End Function
  1092.  
  1093.  
  1094. ' --------------------------------------------------------------
  1095. ' Function:    OTS_GetTableRow
  1096. '
  1097. ' Synopsis:    Get a row for the table
  1098. ' Arguments: [in] Table
  1099. '            [out] RowOut array variable for a single row
  1100. '
  1101. ' Return    gc_ERR_SUCCESS or error code
  1102. '
  1103. ' --------------------------------------------------------------
  1104. Private Function OTS_GetTableRow(ByRef Table, ByVal RowNumber, ByRef RowOut)
  1105.     Dim rows
  1106.     Dim rc
  1107.     rc = gc_ERR_SUCCESS
  1108.  
  1109.     SA_ClearError()
  1110.     rc = OTS_GetTableRows(Table, rows)
  1111.     If ( rc = gc_ERR_SUCCESS ) Then
  1112.         If (RowNumber < UBound(rows) ) Then
  1113.  
  1114.             If IsArray(rows(RowNumber)) Then
  1115.                 RowOut = rows(RowNumber)
  1116.             Else
  1117.                 rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, _ 
  1118.                                 "OTS_GetTableRow")
  1119.             End If
  1120.         Else
  1121.             rc = SA_SetLastError(OTS_ERR_INVALID_ROW, _
  1122.                                 "OTS_GetTableRow")
  1123.         End If
  1124.     Else
  1125.         '
  1126.         ' Error already set by GetTableRows
  1127.         '
  1128.     End If
  1129.  
  1130.     OTS_GetTableRow = rc
  1131.     
  1132. End Function
  1133.  
  1134.  
  1135.  
  1136. ' --------------------------------------------------------------
  1137. ' Function:    OTS_GetTableTasks
  1138. '
  1139. ' Synopsis:    Get the table tasks
  1140. ' Arguments: [in] Table
  1141. '            [out] TasksOut Two dimensional array of table tasks
  1142. '
  1143. ' Return    gc_ERR_SUCCESS or error code
  1144. '
  1145. ' --------------------------------------------------------------
  1146. Private Function OTS_GetTableTasks(ByRef Table, ByRef TasksOut)
  1147.     Dim rc
  1148.     rc = gc_ERR_SUCCESS
  1149.  
  1150.     SA_ClearError()
  1151.     If (OTS_IsValidTable(Table) ) Then
  1152.         If (IsArray(Table(OTS_TABLE_TASKS))) Then
  1153.             TasksOut = Table(OTS_TABLE_TASKS)
  1154.         Else
  1155.             rc = SA_SetLastError(OTS_ERR_TASK_NOT_ARRAYTYPE, _
  1156.                                 "OTS_GetTableTasks")
  1157.         End If
  1158.     Else
  1159.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1160.                                 "OTS_GetTableTasks")
  1161.     End If
  1162.     
  1163.     OTS_GetTableTasks = rc
  1164. End Function
  1165.  
  1166.  
  1167.  
  1168. ' --------------------------------------------------------------
  1169. ' Function:    OTS_GetTableColumns
  1170. '
  1171. ' Synopsis:    Get the table columns
  1172. ' Arguments: [in] Table
  1173. '            [out] ColumnsOut array of table columns
  1174. '
  1175. ' Return    gc_ERR_SUCCESS or error code
  1176. '
  1177. ' --------------------------------------------------------------
  1178. Private Function OTS_GetTableColumns(ByRef Table, ByRef ColumnsOut)
  1179.     Dim rc
  1180.     rc = gc_ERR_SUCCESS
  1181.     
  1182.     SA_ClearError()
  1183.     If (OTS_IsValidTable(Table) ) Then
  1184.         If (IsArray(Table(OTS_TABLE_COLS))) Then
  1185.             ColumnsOut = Table(OTS_TABLE_COLS)
  1186.         Else
  1187.             rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, _
  1188.                                 "OTS_GetTableColumns")
  1189.         End If
  1190.     Else
  1191.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1192.                                 "OTS_GetTableColumns")
  1193.     End If
  1194.  
  1195.     OTS_GetTableColumns = rc
  1196. End Function
  1197.  
  1198.  
  1199. ' --------------------------------------------------------------
  1200. ' Function:    OTS_GetColumnAttributes
  1201. '
  1202. ' Synopsis:    Get the array of column attributes
  1203. ' Arguments: [in] Table
  1204. '            [out] AttributesOut array of column attributes, one
  1205. '                 element for each column.
  1206. '
  1207. ' Return    gc_ERR_SUCCESS or error code
  1208. '
  1209. ' --------------------------------------------------------------
  1210. Private Function OTS_GetColumnAttributes(ByRef Table, ByRef AttributesOut)
  1211.     Dim rc
  1212.     rc = gc_ERR_SUCCESS
  1213.     
  1214.     SA_ClearError()
  1215.     If (OTS_IsValidTable(Table) ) Then
  1216.         Dim columns
  1217.         rc = OTS_GetTableColumns(Table, columns)
  1218.         If (rc = gc_ERR_SUCCESS) Then
  1219.             Dim count
  1220.             Dim index
  1221.             Dim Attributes()
  1222.  
  1223.             count = UBound(columns)
  1224.             ReDim Attributes(count)
  1225.             For index = 0 to (count-1)
  1226.                 Dim colAttr
  1227.                 
  1228.                 rc = OTS_GetColumnFlags(columns(index), colAttr)
  1229.                 if ( rc <> gc_ERR_SUCCESS) Then
  1230.                     OTS_GetColumnAttributes = rc
  1231.                     Exit Function
  1232.                 End If
  1233.                 
  1234.                 Attributes(index) = colAttr
  1235.                 
  1236.             Next
  1237.             AttributesOut = Attributes
  1238.         Else
  1239.             '
  1240.             ' Error set by GetTableColumns
  1241.             '
  1242.         End If
  1243.     Else
  1244.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1245.                             "OTS_GetColumnAttributes")
  1246.     End If
  1247.     
  1248.     OTS_GetColumnAttributes = rc
  1249. End Function
  1250.  
  1251.  
  1252. ' --------------------------------------------------------------
  1253. ' Function:    OTS_GetTableCaption
  1254. '
  1255. ' Synopsis:    Get the table heading
  1256. ' Arguments: [in] Table
  1257. '            [out] CaptionOut the caption
  1258. '
  1259. ' Return    gc_ERR_SUCCESS or error code
  1260. '
  1261. ' --------------------------------------------------------------
  1262. Private Function OTS_GetTableCaption(ByRef Table, ByRef CaptionOut)
  1263.     Dim rc
  1264.     rc = gc_ERR_SUCCESS
  1265.     
  1266.     SA_ClearError()
  1267.     If (OTS_IsValidTable(Table) ) Then
  1268.         CaptionOut = Table(OTS_TABLE_CAPTION)
  1269.     Else
  1270.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1271.                             "OTS_GetTableCaption")
  1272.     End If
  1273.  
  1274.     OTS_GetTableCaption = rc
  1275. End Function
  1276.  
  1277. ' --------------------------------------------------------------
  1278. ' Function:    OTS_GetTableDescription
  1279. '
  1280. ' Synopsis:    Get the table description
  1281. ' Arguments: [in] Table
  1282. '            [out] TitleOut the title
  1283. '
  1284. ' Return    gc_ERR_SUCCESS or error code
  1285. '
  1286. ' --------------------------------------------------------------
  1287. Private Function OTS_GetTableDescription(ByRef Table, ByRef TitleOut)
  1288.     Dim rc
  1289.     rc = gc_ERR_SUCCESS
  1290.     
  1291.     SA_ClearError()
  1292.     If (OTS_IsValidTable(Table) ) Then
  1293.         TitleOut  = Table(OTS_TABLE_DESC)
  1294.     Else
  1295.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1296.                                 "OTS_GetTableDescription")
  1297.     End If
  1298.  
  1299.     OTS_GetTableDescription = rc
  1300. End Function
  1301.  
  1302.  
  1303. ' --------------------------------------------------------------
  1304. ' Function:    OTS_GetTableID
  1305. '
  1306. ' Synopsis:    Get the table's HTML ID TAG. If the table ID has 
  1307. '            not been set then we initialize it here.
  1308. ' Arguments: [in] Table
  1309. '            [out] TableId id of the table
  1310. '
  1311. ' Return    gc_ERR_SUCCESS or error code
  1312. '
  1313. ' --------------------------------------------------------------
  1314. Private Function OTS_GetTableID(ByRef Table, ByRef TableIdOut)
  1315.     Dim rc
  1316.     rc = gc_ERR_SUCCESS
  1317.     
  1318.     SA_ClearError()
  1319.     If (OTS_IsValidTable(Table) ) Then
  1320.         If (IsEmpty(Table(OTS_TABLE_ID))) Then
  1321.             Table(OTS_TABLE_ID) = OTS_TABLE_OBJECT_ID _
  1322.                                 + CStr(OTS_TABLE_NEXT_ID)
  1323.                                 
  1324.             OTS_TABLE_NEXT_ID = OTS_TABLE_NEXT_ID + 1
  1325.         End If
  1326.         TableIdOut = Table(OTS_TABLE_ID)
  1327.     Else
  1328.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableID")
  1329.     End If
  1330.  
  1331.     OTS_GetTableID = rc
  1332. End Function
  1333.  
  1334.  
  1335. ' --------------------------------------------------------------
  1336. ' Function:    OTS_SetTableID
  1337. '
  1338. ' Synopsis:    Set the table ID
  1339. ' Arguments: [in] Table
  1340. '            [in] TableID table id
  1341. '
  1342. ' Return    gc_ERR_SUCCESS or error code
  1343. '
  1344. ' --------------------------------------------------------------
  1345. Public Function OTS_SetTableID(ByRef Table, ByVal TableID)
  1346.     Dim rc
  1347.     rc = gc_ERR_SUCCESS
  1348.     
  1349.     SA_ClearError()
  1350.     If (OTS_IsValidTable(Table) ) Then
  1351.         Table(OTS_TABLE_ID) = TableID
  1352.     Else
  1353.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableID")
  1354.     End If
  1355.  
  1356.     OTS_SetTableID = rc
  1357. End Function
  1358.  
  1359.  
  1360. ' --------------------------------------------------------------
  1361. ' Function:    OTS_GetTableSize
  1362. '
  1363. ' Synopsis:    Calculate the table size in Rows and Columns
  1364. '
  1365. ' Arguments: [in] Table
  1366. '            [out] RowsOut rows in longest column
  1367. '            [out] ColsOut number of columns
  1368. ' Return    gc_ERR_SUCCESS or error code
  1369. '
  1370. ' --------------------------------------------------------------
  1371. Private Function OTS_GetTableSize(ByRef Table, ByRef RowsOut, ByRef ColsOut)
  1372.     Dim rowCt
  1373.     Dim colCt
  1374.     Dim count
  1375.     Dim columns
  1376.     Dim rows
  1377.     Dim rc
  1378.     rc = gc_ERR_SUCCESS
  1379.     
  1380.     SA_ClearError()
  1381.     If (OTS_IsValidTable(Table)) Then
  1382.         rc = OTS_GetTableColumns(Table, columns)
  1383.         If (rc = gc_ERR_SUCCESS) Then
  1384.             colCt = UBound(columns)
  1385.  
  1386.             rc = OTS_GetTableRows(Table, rows)
  1387.             If (rc = gc_ERR_SUCCESS) Then
  1388.  
  1389.                 rowCt = UBound(rows)
  1390.  
  1391.                 RowsOut = rowCt
  1392.                 ColsOut = colCt
  1393.                 
  1394.             Else If ( rc = OTS_ERR_NO_ROWS ) Then
  1395.                     rc = gc_ERR_SUCCESS
  1396.                     SA_ClearError()
  1397.                     RowsOut = 0
  1398.                     ColsOut = colCt
  1399.                 End If
  1400.                 
  1401.             End If
  1402.         Else
  1403.             '
  1404.             ' GetTableColumns set last error
  1405.             '
  1406.         End If
  1407.     
  1408.     Else
  1409.         rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSize")
  1410.     End If
  1411.     
  1412.     OTS_GetTableSize = rc
  1413. End Function
  1414.  
  1415.  
  1416. ' --------------------------------------------------------------
  1417. ' Function:    OTS_ServeTable
  1418. '
  1419. ' Synopsis:    Render the specified table as HTML
  1420. ' --------------------------------------------------------------
  1421. Public Function OTS_ServeTable(ByRef Table)
  1422.     OTS_ServeTable = OTS_ServeTaskViewTable(Table)
  1423. End Function
  1424.  
  1425. Public Function OTS_ServeTaskViewTable(ByRef Table)
  1426.     Dim rc
  1427.         
  1428.     rc = gc_ERR_SUCCESS
  1429.     
  1430.     SA_ClearError()
  1431.     
  1432.     '
  1433.     ' Validate the table
  1434.     '
  1435.     If (NOT OTS_IsValidTable(Table)) Then
  1436.         '
  1437.         ' This is a big function so I am short circuiting the exit point
  1438.         ' to make it easier to follow the logic.
  1439.         '
  1440.         OTS_ServeTaskViewTable = _
  1441.                 SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1442.                                 "OTS_ServeTaskViewTable")
  1443.                                 
  1444.         Exit Function
  1445.     End If
  1446.  
  1447.  
  1448.     '
  1449.     ' Check sorting option, this SAK 1.X backward compatibility feature.
  1450.     ' SAK 2.0 uses should be calling OTS_SortTable(Table, sortCol, sortSequence, bUseCompareCallback)
  1451.     '
  1452.     If ( SA_GetVersion() < gc_V2 ) Then
  1453.         Dim bSortEnabled
  1454.         rc = OTS_IsTableSortEnabled(Table, bSortEnabled) 
  1455.         If ( rc <> gc_ERR_SUCCESS ) Then
  1456.             '
  1457.             ' IsTableSortEnabled set the last error. I am short circuiting the
  1458.             ' exit point to make the logic easier to follow.
  1459.             '
  1460.             OTS_ServeTaskViewTable = rc
  1461.             Exit Function
  1462.         End If
  1463.         If ( bSortEnabled ) Then
  1464.             'Call SA_TraceOut("OTS_TABLE", "Sorting table")
  1465.             
  1466.             Dim sseq
  1467.             Call OTS_GetTableSortSequence(Table, sseq)
  1468.  
  1469.             Dim keyCol
  1470.             Call OTS_GetTableSortColumn(Table, keyCol)
  1471.             
  1472.             rc = OTS_SortTable(Table, keyCol, sseq, FALSE)
  1473.         End If
  1474.     End If
  1475.     
  1476.  
  1477.     '
  1478.     ' Outer Table for nifty border and Caption
  1479.     '
  1480.  
  1481.     If OTS_IsAutoInitEnabled(Table) Then
  1482.         OTS_EmitAutoInitJavascript(Table)    
  1483.     End If
  1484.  
  1485.     
  1486.     'Response.Write("<TABLE cols=1 border='0' cellspacing='0' cellpadding='0'")
  1487.     'Response.Write("  width='550px' height='275px' class='ObjTaskHeaderFrame' >"+vbCrLf)
  1488.     
  1489.     '
  1490.     ' Caption
  1491.     '
  1492.     Dim tableCaption
  1493.     rc = OTS_GetTableCaption(Table, tableCaption)
  1494.     If ( rc <> gc_ERR_SUCCESS) Then
  1495.         OTS_ServeTaskViewTable = rc
  1496.         Exit Function
  1497.     End If
  1498.  
  1499.     ' Page Title bar was moved into FRAMEWORK in SAK 2.0. Following code is to allow
  1500.     ' SAK 1.x code to continue working.
  1501.     If ( NOT SA_IsCurrentPageType(PT_AREA)) Then
  1502.         Response.Write("<div class='PageHeaderBar'>")
  1503.         Response.Write(Server.HTMLEncode(tableCaption))
  1504.         Response.Write("</div></br>")
  1505.     End If
  1506.     
  1507.     '
  1508.     ' Description
  1509.     '
  1510.     Dim tableDescription
  1511.     rc = OTS_GetTableDescription(Table, tableDescription)
  1512.     If ( rc <> gc_ERR_SUCCESS) Then
  1513.         OTS_ServeTaskViewTable = rc
  1514.         Exit Function
  1515.     End If
  1516.  
  1517.     'Response.Write("<div  class='PageDescriptionText'>")
  1518.     'Response.Write(Server.HTMLEncode(tableDescription)+"</div>")
  1519.     Response.Write(Server.HTMLEncode(tableDescription))
  1520.    
  1521.  
  1522.     'Put it in a div to center everything    
  1523.     ' Response.Write("<div class=PageBodyInnerIndent >")
  1524.     Response.Write("<BR><BR>")
  1525.  
  1526.     '
  1527.     ' Inner Table containing Items, spacer column, and Tasks
  1528.     '
  1529.     Response.Write("<table cols=3 border=0 cellpadding=0 cellspacing=0 width='550px' height='250px'")
  1530.     Response.Write(" class='ObjHeaderFrame' id='moduleContents2'>"+vbCrLf)
  1531.  
  1532.     Call OTS_RenderTableToolBar(Table)
  1533.  
  1534.     '
  1535.     ' Inner Table has one row
  1536.     Response.Write("<tr height='250px' valign='top'>"+vbCrLf)
  1537.  
  1538.     '
  1539.     ' First cell contains items
  1540.     '
  1541.     Response.Write("<td width='550px' valign='top'>"+vbCrLf)
  1542.     
  1543.     '
  1544.     ' DIV to handle scrolling of items: I thing this DIV is obsolete...
  1545.     '
  1546.     If ( OTS_IsExplorer() ) Then
  1547.           Response.Write("<div style='valign:top;width:550px;height:100%;overflow:auto'>"+vbCrLf)
  1548.     End If    
  1549.  
  1550.     '
  1551.     ' Render the items
  1552.     '
  1553.     rc = OTS_RenderTaskItems(Table)
  1554.     If ( rc <> gc_ERR_SUCCESS ) Then
  1555.         OTS_ServeTaskViewTable = rc
  1556.     End If
  1557.  
  1558.     Dim sPKeyParamName
  1559.     Call OTS_GetTablePKeyName(table, sPKeyParamName)
  1560.  
  1561.     Dim bColumnSortingEnabled
  1562.     bColumnSortingEnabled =    OTS_IsColumnSortEnabled(Table)
  1563.     
  1564.     Dim sortCol
  1565.     Call OTS_GetTableSortColumn( Table, sortCol)
  1566.  
  1567.     Dim sortSequence
  1568.     Call OTS_GetTableSortSequence(Table, sortSequence)
  1569.     
  1570.     sortSequence = SA_GetParam(FLD_SortingSequence)
  1571.     If ( Len(Trim(sortSequence)) <= 0 ) Then
  1572.         sortSequence = "A"
  1573.     End If
  1574.     
  1575.     Dim iPageMin
  1576.     Dim iPageMax
  1577.     Dim iPageCurrent
  1578.     Dim bPagingEnabled
  1579.     
  1580.     Call OTS_GetPagingRange( Table, bPagingEnabled, iPageMin, iPageMax, iPageCurrent)
  1581.  
  1582.     Response.Write("<input type=hidden name='tSelectedItem' value='"+Request.Form("tSelectedItem")+"'>"+vbCrLf)
  1583.     Response.Write("<input type=hidden name='tSelectedItemNumber' value='"+Request.Form("tSelectedItemNumber")+"' >"+vbCrLf)
  1584.     Response.Write("<input type=hidden name='fldPKeyParamName' value='"+sPKeyParamName+"' >"+vbCrLf)
  1585.     
  1586.     Response.Write("<input type=hidden name='"+FLD_SearchRequest+"' value='0' >"+vbCrLf)
  1587.  
  1588.     Response.Write("<input type=hidden name='"+FLD_PagingRequest+"' value='0' >"+vbCrLf)
  1589.     Response.Write("<input type=hidden name='"+FLD_PagingAction+"' value='' >"+vbCrLf)
  1590.     Response.Write("<input type=hidden name='"+FLD_PagingPageMin+"' value='"+CStr(iPageMin)+"' >"+vbCrLf)
  1591.     Response.Write("<input type=hidden name='"+FLD_PagingPageMax+"' value='"+CStr(iPageMax)+"' >"+vbCrLf)
  1592.     Response.Write("<input type=hidden name='"+FLD_PagingPageCurrent+"' value='"+CStr(iPageCurrent)+"' >"+vbCrLf)
  1593.  
  1594.     if ( bPagingEnabled ) Then
  1595.         Response.Write("<input type=hidden name='"+FLD_PagingEnabled+"' value='T' >"+vbCrLf)
  1596.     Else
  1597.         Response.Write("<input type=hidden name='"+FLD_PagingEnabled+"' value='F' >"+vbCrLf)
  1598.     End If
  1599.  
  1600.     If ( bColumnSortingEnabled ) Then
  1601.         Response.Write("<input type=hidden name='"+FLD_SortingEnabled+"' value='1' >"+vbCrLf)
  1602.     Else
  1603.         Response.Write("<input type=hidden name='"+FLD_SortingEnabled+"' value='0' >"+vbCrLf)
  1604.     End If
  1605.     Response.Write("<input type=hidden name='"+FLD_SortingRequest+"' value='0' >"+vbCrLf)
  1606.     Response.Write("<input type=hidden name='"+FLD_SortingColumn+"' value='"+CStr(sortCol)+"' >"+vbCrLf)
  1607.     Response.Write("<input type=hidden name='"+FLD_SortingSequence+"' value='"+sortSequence+"' >"+vbCrLf)
  1608.  
  1609.     Response.Write("<input type=hidden name='"+FLD_IsToolbarEnabled+"' value='1' >"+vbCrLf)
  1610.  
  1611.     If ( OTS_IsExplorer() ) Then
  1612.         Response.Write("</div>"+vbCrLf)
  1613.     End If
  1614.     Response.Write("</td>"+vbCrLf)
  1615.                 
  1616.     '
  1617.     ' Second cell is a divider between items and tasks
  1618.     '
  1619.     'Response.Write("<td width=10px> </td>"+vbCrLf)
  1620.  
  1621.     '
  1622.     ' Third cell contains tasks
  1623.     '
  1624.     Response.Write("<td class='TasksTextNoPad' valign='top' width='140px'>"+vbCrLf)
  1625.     '
  1626.     ' Render the tasks
  1627.     '
  1628.     rc = OTS_RenderTasks(Table)
  1629.     If ( rc <> gc_ERR_SUCCESS ) Then
  1630.         OTS_ServeTaskViewTable = rc
  1631.     End If
  1632.     
  1633.     Response.Write("</td>"+vbCrLf)
  1634.     Response.Write("</TR>"+vbCrLf)
  1635.     Response.Write("</TABLE>"+vbCrLf)
  1636.     If ( SA_GetVersion() >=  gc_V2 ) Then
  1637.         '
  1638.         ' Form tag is emitted by Framework
  1639.     Else
  1640.         Response.Write("</form >"+vbCrLf)
  1641.     End If
  1642.     'Response.Write("</div>"+vbCrLf)
  1643.     
  1644.     'Response.Write("</TD>"+vbCrLf)
  1645.     'Response.Write("</TR>"+vbCrLf)
  1646.     'Response.Write("</TABLE>"+vbCrLf)
  1647.  
  1648.     Call OTS_OutputTasksScript(Table)
  1649.     
  1650.     OTS_ServeTaskViewTable = rc
  1651.     
  1652. End Function
  1653.  
  1654.  
  1655. Private Function OTS_RenderTableToolBar(ByRef Table)
  1656.     DIM columns
  1657.     Dim maxRows
  1658.     Dim maxColumns
  1659.     Dim rc
  1660.     Dim rowCount
  1661.     Dim colCount
  1662.     Dim columnObject
  1663.     Dim attributesForColumns
  1664.     Dim bMultiSelect
  1665.  
  1666.     '
  1667.     ' Get the table extents (Max rows and columns)
  1668.     '
  1669.     rc = OTS_GetTableSize(Table, maxRows, maxColumns)
  1670.     If (rc <> gc_ERR_SUCCESS ) Then
  1671.         '
  1672.         ' GetTableSize set the last error
  1673.         '
  1674.         OTS_RenderTableToolBar = rc
  1675.         Exit Function
  1676.     End If
  1677.  
  1678.     '
  1679.     ' Get the table columns
  1680.     '
  1681.     rc = OTS_GetTableColumns(Table, columns)
  1682.     If (rc <> gc_ERR_SUCCESS) Then
  1683.         OTS_RenderTableToolBar = rc
  1684.         Exit Function
  1685.     End If
  1686.  
  1687.     
  1688.     '
  1689.     ' Get attributes for all the columns
  1690.     '
  1691.     rc = OTS_GetColumnAttributes(Table, attributesForColumns)
  1692.     If (rc <> gc_ERR_SUCCESS) Then
  1693.         OTS_RenderTableToolBar = rc
  1694.         Exit Function
  1695.     End If
  1696.  
  1697.     If OTS_IsTableMultiSelection(table) Then
  1698.         bMultiSelect=1
  1699.     Else
  1700.         bMultiSelect=0
  1701.     End If
  1702.     
  1703.     '
  1704.     ' OPTIMIZATION:
  1705.     ' From here on we want the upper limit for the column count
  1706.     '
  1707.     maxColumns = maxColumns - 1
  1708.  
  1709.     Dim bEnableSearch
  1710.     Dim bEnablePaging
  1711.     
  1712.     Dim iPageMin
  1713.     Dim iPageMax
  1714.     Dim iPageCurrent
  1715.     
  1716.     bEnableSearch = OTS_IsSearchEnabled(Table)
  1717.     Call OTS_GetPagingRange(Table, bEnablePaging, iPageMin, iPageMax, iPageCurrent)
  1718.  
  1719.     
  1720.     If ( bEnableSearch OR bEnablePaging  ) Then
  1721.         Response.Write("<tr nowrap height=25px>"+vbCrLf)
  1722.         Response.Write("<TD colspan=3>")
  1723.         
  1724.         Response.Write("<TABLE class=OTSToolBarHeader>")
  1725.         Response.Write("<TR nowrap>")
  1726.     
  1727.             
  1728.         If ( bEnableSearch ) Then
  1729.             Dim L_SEARCH_TEXT
  1730.             Dim L_SEARCH_BUTTON
  1731.             Dim iCurrentSelectedCol
  1732.  
  1733.             L_SEARCH_TEXT = GetLocString("sacoremsg.dll", "40200BBA", "")
  1734.             L_SEARCH_BUTTON = GetLocString("sacoremsg.dll", "40200BBB", "")
  1735.  
  1736.             iCurrentSelectedCol = Int(SA_GetParam(FLD_SearchItem))
  1737.  
  1738.             Response.Write("<TD nowrap style='padding-left:10px;'>"+L_SEARCH_TEXT+"</TD>")
  1739.         
  1740.             Response.Write("<TD>")
  1741.             Response.Write("<select size='1' name='"+FLD_SearchItem+"'>")
  1742.  
  1743.             Dim iSearchColCt
  1744.             iSearchColCt = 0
  1745.             For colCount = 0 to (maxColumns)
  1746.  
  1747.                 
  1748.                 If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1749.                     '
  1750.                     ' Column is hidden
  1751.                     '
  1752.                 ElseIf (attributesForColumns(colCount) AND OTS_COL_FLAG_SEARCH) Then
  1753.                     Dim sSearchColumn
  1754.                     Dim sSelected
  1755.  
  1756.                     iSearchColCt = iSearchColCt + 1
  1757.     
  1758.                     If ( colCount = iCurrentSelectedCol ) Then
  1759.                         sSelected = " selected "
  1760.                     Else
  1761.                         sSelected = ""
  1762.                     End If
  1763.                 
  1764.                     columnObject = columns(colCount)
  1765.                     Call OTS_GetColumnHeading(columnObject, sSearchColumn)
  1766.                     Response.Write("<option value='"+CStr(colCount)+"' "+sSelected+" >"+Server.HTMLEncode(sSearchColumn)+"</option>")
  1767.                 End If
  1768.             Next
  1769.             
  1770.             If (iSearchColCt <= 0 ) Then
  1771.                     Response.Write("<option value='"+CStr(0)+"' >"+Server.HTMLEncode(GetLocString("sacoremsg.dll", "40200BBD", ""))+"</option>")
  1772.             End If
  1773.             
  1774.             Response.Write("</select>")
  1775.             Response.Write("</TD>")
  1776.  
  1777.             Response.Write("<TD>")
  1778.             Response.Write("<input type=text name='"+FLD_SearchValue+"' value="""+Server.HTMLEncode(SA_GetParam(FLD_SearchValue))+""" onChange='OTS_SetSearchChanged();'>")
  1779.             Response.Write("</input>")
  1780.             Response.Write("</TD>")
  1781.         
  1782.             Response.Write("<TD nowrap class=OTSToolBarHeaderRightBorder>")
  1783.             Call SA_ServeOnClickButton(L_SEARCH_BUTTON, "images/butSearchEnabled.gif", "javascript:OTS_SubmitSearch();", 40, 28, "")
  1784.             Response.Write("</TD>")
  1785.         End If
  1786.  
  1787.  
  1788.         If ( bEnablePaging ) Then
  1789.             Dim sAttributes
  1790.             Dim sImage
  1791.             Dim sPageID
  1792.             Dim L_NEXT_BUTTON
  1793.             Dim L_PREVIOUS_BUTTON
  1794.             Dim L_PAGE_X_OF_Y
  1795.             Dim aParam(2)
  1796.             Dim repString
  1797.             aParam(0) = CStr(iPageCurrent)
  1798.             aParam(1) = CStr(iPageMax - iPageMin + 1)
  1799.             repString = aParam
  1800.             
  1801.             L_PAGE_X_OF_Y = GetLocString("sacoremsg.dll", "40200BBE", repString)
  1802.             
  1803.             If ( bEnableSearch ) Then
  1804.                 Response.Write("<TD>")
  1805.                 Response.Write("      ")
  1806.                 Response.Write("</TD>")
  1807.             End If
  1808.  
  1809.             L_NEXT_BUTTON = ""
  1810.             L_PREVIOUS_BUTTON = ""
  1811.             
  1812.  
  1813.             If ( iPageCurrent > iPageMin ) Then
  1814.                 sAttributes = " title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1815.                 sImage = "images/butPagePreviousEnabled.gif"
  1816.             Else
  1817.                 sAttributes = "DISABLED title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1818.                 sImage = "images/butPagePreviousDisabled.gif"
  1819.             End If
  1820.             Response.Write("<TD>")
  1821.             Call SA_ServeOnClickButton(L_PREVIOUS_BUTTON, sImage, "javascript:OTS_SubmitPageChange('prev');", 0, 0, sAttributes)
  1822.             Response.Write("</TD>")
  1823.  
  1824.         
  1825.             If ( iPageCurrent < iPageMax ) Then
  1826.                 sAttributes = " title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1827.                 sImage = "images/butPageNextEnabled.gif"
  1828.             Else
  1829.                 sAttributes = "DISABLED title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1830.                 sImage = "images/butPageNextDisabled.gif"
  1831.             End If
  1832.             Response.Write("<TD class=OTSToolBarHeaderRightBorder>")
  1833.             Call SA_ServeOnClickButton(L_NEXT_BUTTON, sImage, "javascript:OTS_SubmitPageChange('next');", 0, 0, sAttributes)
  1834.             Response.Write("</TD>")
  1835.         End If
  1836.  
  1837.         Response.Write("<TD width='100%'>")
  1838.         Response.Write("</TD>")
  1839.  
  1840.         Response.Write("</TR>"+vbCrLf)
  1841.         Response.Write("</TABLE>")
  1842.         
  1843.         Response.Write("</TD>")
  1844.         Response.Write("</TR>"+vbCrLf)
  1845.     End If
  1846.     
  1847.     OTS_RenderTableToolBar = rc
  1848. End Function
  1849.  
  1850.  
  1851.  
  1852.  
  1853. Private Function OTS_RenderTaskItems(ByRef Table)
  1854.     DIM columns
  1855.     Dim maxRows
  1856.     Dim maxColumns
  1857.     Dim rc
  1858.     Dim rowCount
  1859.     Dim colCount
  1860.     Dim columnObject
  1861.     Dim colAlign
  1862.     Dim attributesForColumns
  1863.     Dim keyColumn
  1864.     Dim sInputType
  1865.     Dim bMultiSelect
  1866.     Dim L_CELLTRUNCATION_TEXT
  1867.     Dim sortCol
  1868.  
  1869.     L_CELLTRUNCATION_TEXT = GetLocString("sacoremsg.dll", "40200BBC", "")
  1870.     
  1871.     
  1872.     '
  1873.     ' Validate the table
  1874.     '
  1875.     If (NOT OTS_IsValidTable(Table)) Then
  1876.         OTS_RenderTaskItems =  SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1877.                                         "OTS_RenderTaskItems")
  1878.         Exit Function
  1879.     End If
  1880.  
  1881.     '
  1882.     ' Get the table extents (Max rows and columns)
  1883.     '
  1884.     rc = OTS_GetTableSize(Table, maxRows, maxColumns)
  1885.     If (rc <> gc_ERR_SUCCESS ) Then
  1886.         '
  1887.         ' GetTableSize set the last error
  1888.         '
  1889.         OTS_RenderTaskItems = rc
  1890.         Exit Function
  1891.     End If
  1892.  
  1893.     '
  1894.     ' Get the table columns
  1895.     '
  1896.     rc = OTS_GetTableColumns(Table, columns)
  1897.     If (rc <> gc_ERR_SUCCESS) Then
  1898.         OTS_RenderTaskItems = rc
  1899.         Exit Function
  1900.     End If
  1901.  
  1902.     '
  1903.     ' Get Key column for table
  1904.     '
  1905.     rc = OTS_GetKeyColumnForTable(Table, keyColumn)
  1906.     If (rc <> gc_ERR_SUCCESS) Then
  1907.         OTS_RenderTaskItems = rc
  1908.         Exit Function
  1909.     End If
  1910.     
  1911.     '
  1912.     ' Get attributes for all the columns
  1913.     '
  1914.     rc = OTS_GetColumnAttributes(Table, attributesForColumns)
  1915.     If (rc <> gc_ERR_SUCCESS) Then
  1916.         OTS_RenderTaskItems = rc
  1917.         Exit Function
  1918.     End If
  1919.  
  1920.     If OTS_IsTableMultiSelection(table) Then
  1921.         sInputType = "checkbox"
  1922.         bMultiSelect=1
  1923.     Else
  1924.         sInputType = "radio"
  1925.         bMultiSelect=0
  1926.     End If
  1927.  
  1928.     Response.Write("<table cols="+CStr(maxColumns)+" border=0 cellpadding=0 cellspacing=0 width='100%'>"+vbCrLf)
  1929.  
  1930.     '
  1931.     ' OPTIMIZATION:
  1932.     ' From here on we want the upper limit for the column count
  1933.     '
  1934.     maxColumns = maxColumns - 1
  1935.  
  1936.     
  1937.     '
  1938.     ' Write column headings
  1939.     '
  1940.     Response.Write("<TR nowrap height=25px>"+vbCrLf)
  1941.     Dim bIsFirstVisibleCol
  1942.     bIsFirstVisibleCol = true
  1943.  
  1944.     Dim sSortSequence
  1945.     Dim sSortImage
  1946.     Dim sSortImageURL
  1947.     
  1948.     Call OTS_GetTableSortSequence(Table, sSortSequence)
  1949.     If (Trim(UCase(sSortSequence)) = "A") Then
  1950.         sSortSequence = "A"
  1951.         sSortImageURL = "images/butSortAscending.gif"
  1952.     Else
  1953.         sSortSequence = "D"
  1954.         sSortImageURL = "images/butSortDescending.gif"
  1955.     End If
  1956.     
  1957.     Call OTS_GetTableSortColumn(Table, sortCol)
  1958.     
  1959.     For colCount = 0 to (maxColumns)
  1960.         Dim sOnClickColHeading
  1961.         
  1962.         If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1963.             '
  1964.             ' Column is hidden
  1965.             '
  1966.         Else
  1967.             Dim colHeading
  1968.             Dim bIsSortable
  1969.             
  1970.             columnObject = columns(colCount)
  1971.  
  1972.             If ( attributesForColumns(colCount) AND OTS_COL_SORT ) Then
  1973.                 bIsSortable = TRUE
  1974.             Else
  1975.                 bIsSortable = FALSE
  1976.             End If
  1977.  
  1978.             rc = OTS_GetColumnHeading(columnObject, colHeading)
  1979.             If (rc <> gc_ERR_SUCCESS) Then
  1980.                 OTS_RenderTaskItems = rc
  1981.                 Exit Function
  1982.             End If
  1983.             
  1984.             rc = OTS_GetColumnAlign(columnObject, colAlign)
  1985.             If (rc <> gc_ERR_SUCCESS) Then
  1986.                 OTS_RenderTaskItems = rc
  1987.                 Exit Function
  1988.             End If
  1989.  
  1990.             sSortImage = ""
  1991.             sOnClickColHeading = " "
  1992.                If ( SA_GetVersion() >= gc_V2 ) Then
  1993.                 If ( TRUE = bIsSortable ) Then
  1994.                     sOnClickColHeading = " onClick=""OTS_SubmitSort('"+CStr(colCount)+"', '"+sSortSequence+"');"" "
  1995.                     If ( colCount = sortCol ) Then
  1996.                         sSortImage = "<img src='"+m_VirtualRoot+sSortImageURL+"' >"
  1997.                     End If
  1998.                 End If
  1999.             End If
  2000.  
  2001.             
  2002.             If (bIsFirstVisibleCol) Then
  2003.                 bIsFirstVisibleCol = false
  2004.                 
  2005.                 If ( bMultiSelect ) Then
  2006.                     Response.Write("<TD class='ObjHeaderTitleNoVLine' align=center nowrap >")
  2007.                     Response.Write("<input type=checkbox name=fldMacroMultiSelect onClick=OTS_OnMacroMultiSelect()>")
  2008.                     Response.Write("</TD>")
  2009.                 Else
  2010.                     Response.Write("<TD class='ObjHeaderTitleNoVLine'> </TD>")
  2011.                 End If
  2012.                 
  2013.                 Response.Write("<TD "+sOnClickColHeading+" class='ObjHeaderTitle' align="+colAlign+" nowrap>"+_
  2014.                             Server.HTMLEncode(colHeading)+" "+sSortImage+" </TD>")
  2015.             Else
  2016.                 Response.Write("<TD "+sOnClickColHeading+" class='ObjHeaderTitle' align="+colAlign+" nowrap>"+_
  2017.                             Server.HTMLEncode(colHeading)+" "+sSortImage+" </TD>")
  2018.             End If
  2019.             
  2020.                         
  2021.         End If
  2022.     Next
  2023.     Response.Write("</TR>"+vbCrLf)
  2024.  
  2025.     '
  2026.     ' Write table data
  2027.     '
  2028.     Dim keyId
  2029.     Dim selectId
  2030.     Dim tableId
  2031.  
  2032.     
  2033.     rc = OTS_GetTableID(Table, tableId)
  2034.     If (rc <> gc_ERR_SUCCESS) Then
  2035.         OTS_RenderTaskItems = rc
  2036.         Exit Function
  2037.     End If
  2038.     
  2039.     selectId = Quote("TVItem_"+tableId)
  2040.     Dim selectRowClass
  2041.     
  2042.     If (OTS_IsExplorer()) Then
  2043.         selectRowClass = "SelectedRow"
  2044.     Else
  2045.         selectRowClass = "AlternatingDark"
  2046.     End If
  2047.     
  2048.  
  2049.     Dim thisRowClass
  2050.     Dim maxDispRows
  2051.     Dim minDispRows
  2052.     minDispRows = 9 'We will always output at least 1+ this many rows
  2053.  
  2054.     maxDispRows = Max(minDispRows, (maxRows - 1))
  2055.     
  2056.     If ( maxRows > 0 ) Then 
  2057.         For rowCount = 0 to (maxDispRows)
  2058.             Dim rowData
  2059.             Dim sOnRowClicked
  2060.  
  2061.  
  2062.             '
  2063.             ' OnClick handler only applies to data rows
  2064.             '
  2065.             If ( rowCount < maxRows ) Then
  2066.                 sOnRowClicked = "onClick=""return OTS_RowClicked('"+CStr(rowCount)+"')"" "
  2067.             Else
  2068.                 sOnRowClicked = ""
  2069.             End If
  2070.  
  2071.             
  2072.             If ( rowCount Mod 2 ) Then
  2073.                 ' onselectstart='return false;' 
  2074.                 ' onmousemove=""OTS_OnMouseMove('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');"" 
  2075.                 ' onmousedown=""return OTS_OnMouseDown('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');"" 
  2076.                 ' onmouseup=""return OTS_OnMouseUp('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');""
  2077.                 
  2078.                 Response.Write("<TR onselectstart='return false;' "+sOnRowClicked+" id = row"+CStr(rowCount)_
  2079.                         +" height=22px class='AlternatingLight'>"+vbCrLf)
  2080.                 thisRowClass = "AlternatingLight"
  2081.             Else
  2082.                 If (rowCount = 0) Then
  2083.                     Response.Write("<TR onselectstart='return false;'  "+sOnRowClicked+" id = row"+CStr(rowCount)_
  2084.                         +" height=22px class='AlternatingDark' >"+vbCrLf)
  2085.                 Else
  2086.                     Response.Write("<TR onselectstart='return false;'  "+sOnRowClicked+" id = row"+CStr(rowCount)_
  2087.                         +" height=22px class='AlternatingDark' >"+vbCrLf)
  2088.                 End If
  2089.                 thisRowClass = "AlternatingDark"
  2090.             End If
  2091.  
  2092.            If ( rowCount < maxRows ) Then
  2093.  
  2094.             rc = OTS_GetTableRow(Table, rowCount, rowData)
  2095.             If (rc <> gc_ERR_SUCCESS) Then
  2096.                 OTS_RenderTaskItems = rc
  2097.                 Exit Function
  2098.             End If
  2099.         
  2100.             '
  2101.             ' Verify row has correct number of columns
  2102.             '
  2103.             If (maxColumns < UBound(rowData)) Then
  2104.                 SA_TraceOut "ServeTaskViewTable", ("maxColumns:"+_
  2105.                                 CStr(maxColumns)+_
  2106.                                 " < UBound(rowData):"+_
  2107.                                 CStr(UBound(rowData)))
  2108.                 Exit Function
  2109.             End If
  2110.  
  2111.             '
  2112.             ' Extract the key column
  2113.             '
  2114.             keyId = CStr(rowData(keyColumn))
  2115.         
  2116.  
  2117.             '
  2118.             ' Write the first column
  2119.             '
  2120.             Dim onClickHandler
  2121.             keyId = FormatJScriptString(keyId)
  2122.             
  2123.             onClickHandler = " onClick=""return OTS_OnItemClicked('"+keyId+"','"+CStr(rowCount)+"');"" "
  2124.  
  2125.             'If (OTS_IsExplorer()) Then
  2126.             '    onClickHandler = " onClick='OTS_OnItemClicked("""+keyId+""","""+CStr(rowCount)+""");' "
  2127.             'Else
  2128.             '    onClickHandler = " onClick='OTS_OnItemClicked("""+keyId+""","""+CStr(rowCount)+""");'"
  2129.             'End If
  2130.  
  2131.             
  2132.  
  2133.             'No vertical line on the first cell, it contains the input(radio/checkbox) control
  2134.             Response.Write("<TD align=center class="+thisRowClass+"NoVline>"+vbCrLf)
  2135.             'Response.Write("<font face='Tahoma'>")
  2136.             If ( rowCount = 0 ) Then
  2137.                 If ( bMultiSelect = 1 ) Then
  2138.                     Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  2139.                                 onClickHandler+_
  2140.                                 " type="+sInputType+" value="""+keyId+""" name="+selectId+">")
  2141.                 Else
  2142.                     Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  2143.                                 onClickHandler+_
  2144.                                 " type="+sInputType+" checked value="""+keyId+""" name="+selectId+">")
  2145.                 End If
  2146.                 Response.Write("</font>")
  2147.  
  2148.             'Need to make sure that we have an array so we will send a hidden radio button
  2149.                 If ( maxRows = 1 ) Then
  2150.                     Response.Write("<INPUT id=radio"+CStr(rowCount+1)+_
  2151.                         " type="+sInputType+" value="""+keyId+"2_RowHidden" + """ name="+selectId+" style='display:none'>")
  2152.                         Response.Write("</font>")
  2153.                 End If
  2154.             Else 
  2155.                 Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  2156.                     onClickHandler+_
  2157.                     " type="+sInputType+" value="""+keyId+""" name="+selectId+">")
  2158.                     Response.Write("</font>")
  2159.             End If
  2160.            Else 'output a blank cell
  2161.             Response.Write("<TD  class="+thisRowClass+"NoVline> "+vbCrLf)
  2162.            End If
  2163.  
  2164.             Response.Write(vbCrLf+"</TD>"+vbCrLf)
  2165.  
  2166.             For colCount = 0 to maxColumns
  2167.                 Dim cellData
  2168.  
  2169.             
  2170.                 If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  2171.                     '
  2172.                     ' Column is hidden
  2173.                     '
  2174.  
  2175.                 Else
  2176.  
  2177.                   If ( rowCount < maxRows ) Then
  2178.                       Dim sCellTitle
  2179.                     Dim iCellWidth
  2180.                     
  2181.                     '
  2182.                     ' Column is visible
  2183.                     '
  2184.                     cellData = rowData(colCount)
  2185.                     colAlign = (columns(colCount))(OTS_COL_ALIGN)
  2186.                     
  2187.                     sCellTitle = ""
  2188.                     If ( OTS_IsColumnWidthDynamic(columns(colCount)) ) Then
  2189.                         Call OTS_GetColumnWidth( columns(colCount), iCellWidth)
  2190.                         If ( LEN(cellData) > iCellWidth ) Then
  2191.                             sCellTitle = " title=""" + Server.HTMLEncode(cellData) + """ "
  2192.                             cellData = Left(cellData, iCellWidth) + L_CELLTRUNCATION_TEXT
  2193.                         End If
  2194.                         
  2195.                     End If
  2196.                     
  2197.                     Response.Write("<TD " + sCellTitle + " onselectstart='return false;' align="+colAlign+" class="+thisRowClass+">"+vbCrLf)
  2198.  
  2199.                     '
  2200.                     ' Write the cell data
  2201.                     '
  2202.                     If cellData="" then
  2203.                         Response.Write(" ")
  2204.                     Else
  2205.                         Response.Write(Server.HTMLEncode((cellData)))
  2206.                     End If
  2207.  
  2208.                     
  2209.                     Response.Write("</TD>"+vbCrLf)
  2210.                 Else 'output a blank cell
  2211.                     Response.Write("<TD class="+thisRowClass+"> </td>"+vbCrLf)
  2212.  
  2213.                 End If
  2214.                  End If
  2215.  
  2216.             
  2217.             Next ' Columns
  2218.             Response.Write("</TR>"+vbCrLf)
  2219.         Next ' Rows
  2220.     Else
  2221.         For rowCount = 0 to minDispRows
  2222.             If ( rowCount Mod 2 ) Then
  2223.             
  2224.                 Response.Write("<TR height=22px class='AlternatingLightNoVline'>"+vbCrLf)
  2225.                 Response.Write("<TD class='AlternatingLightNoVline'> </td>"+vbCrLf)
  2226.                 
  2227.                 For colCount = 0 to (maxColumns)
  2228.                     If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  2229.                     Else
  2230.                         Response.Write("<TD class='AlternatingLight'> </td>"+vbCrLf)
  2231.                     End If
  2232.                 Next
  2233.             Else
  2234.                 Response.Write("<TR height=22px class='AlternatingDark' >"+vbCrLf)
  2235.                 Response.Write("<TD class='AlternatingDarkNoVline'> </td>"+vbCrLf)
  2236.                 
  2237.                 For colCount = 0 to (maxColumns)
  2238.                     If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  2239.                     Else
  2240.                         Response.Write("<TD class='AlternatingDark'> </td>"+vbCrLf)
  2241.                     End If
  2242.                 Next
  2243.             End If
  2244.             Response.Write("</TR>"+vbCrLf)
  2245.         Next
  2246.     End If
  2247.     Response.Write("</TABLE>"+vbCrLf)
  2248.  
  2249.     OTS_RenderTaskItems = rc
  2250. End Function
  2251.  
  2252.  
  2253.  
  2254. Private Function OTS_RenderTasks(ByRef Table)
  2255.     Dim rc
  2256.     DIM tasks
  2257.     DIM rowCount
  2258.     DIM maxRows
  2259.     DIM tasksTitle
  2260.     DIM pKeyName
  2261.     Dim bMultiSelect
  2262.     
  2263.     rc = gc_ERR_SUCCESS
  2264.     
  2265.     '
  2266.     ' Validate the table
  2267.     '
  2268.     If (NOT OTS_IsValidTable(Table)) Then
  2269.         OTS_RenderTasks = SA_SetLastError(OTS_ERR_INVALID_TABLE,_
  2270.                                 "OTS_RenderTasks")
  2271.         Exit Function
  2272.     End If
  2273.  
  2274.     '
  2275.     ' Get tasks data
  2276.     '
  2277.     rc = OTS_GetTableTasks(Table, tasks)
  2278.     If (rc <> gc_ERR_SUCCESS) Then
  2279.         OTS_RenderTasks = rc
  2280.         Exit Function
  2281.     End If
  2282.  
  2283.     '
  2284.     ' Get tasks title
  2285.     '
  2286.     rc = OTS_GetTableTasksTitle(Table, tasksTitle)
  2287.     If (rc <> gc_ERR_SUCCESS) Then
  2288.         OTS_RenderTasks = rc
  2289.         Exit Function
  2290.     End If
  2291.  
  2292.     Dim selectId
  2293.     Dim tableId
  2294.     rc = OTS_GetTableID(Table, tableId)
  2295.     If (rc <> gc_ERR_SUCCESS) Then
  2296.         OTS_RenderTasks = rc
  2297.         Exit Function
  2298.     End If
  2299.  
  2300.  
  2301.     rc = OTS_GetTablePKeyName( Table, pKeyName)
  2302.     If (rc <> gc_ERR_SUCCESS) Then
  2303.         OTS_RenderTasks = rc
  2304.         Exit Function
  2305.     End If
  2306.     
  2307.     If OTS_IsTableMultiSelection(table) Then
  2308.         bMultiSelect = 1
  2309.     Else
  2310.         bMultiSelect = 0
  2311.     End If
  2312.     
  2313.     selectId = "TVItem_"+tableId
  2314.  
  2315.     Response.Write("<table cols=1 width='140px' border=0 cellpadding=0 cellspacing=0 class='TasksTable'")
  2316.     
  2317.     Response.Write(">"+vbCrLf)
  2318.  
  2319.     '
  2320.     ' Task Table Header
  2321.     Response.Write("<TR height='25px'>")
  2322.     Response.Write("<TD class='TasksHeaderTitle'>")
  2323.     Response.Write(Server.HTMLEncode(tasksTitle))
  2324.     Response.Write("</TD>")
  2325.     Response.Write("</TR>"+vbCrLf)
  2326.     
  2327.     '
  2328.     ' Write task table
  2329.     '
  2330.     maxRows = UBound(tasks)
  2331.     For rowCount = 0 to (maxRows-1)
  2332.         Dim taskName
  2333.         Dim taskDesc
  2334.         Dim taskLink
  2335.         Dim task
  2336.         Dim taskHoverText
  2337.         Dim taskPageType
  2338.         
  2339.         Response.Write("<TR height='20px'>")
  2340.  
  2341.         task = tasks(rowCount)
  2342.         If (NOT IsArray(task)) Then
  2343.             OTS_RenderTasks = SA_SetLastError(OTS_ERR_TASK_NOT_ARRAYTYPE,_
  2344.                                         "OTS_RenderTasks")
  2345.             Exit Function
  2346.         End If
  2347.         
  2348.         
  2349.         taskName = task(OTS_TASK_TASK)
  2350.         'taskDesc = FormatJScriptString(task(OTS_TASK_DESC))
  2351.         taskDesc = Server.HTMLEncode(SA_EscapeQuotes(task(OTS_TASK_DESC)))
  2352.         taskHoverText = " title=""" + Server.HTMLEncode(task(OTS_TASK_DESC)) + """"
  2353.         taskLink = task(OTS_TASK_LINK)
  2354.         taskLink = FormatJScriptString(taskLink)
  2355.         taskPageType = task(OTS_TASK_PAGE_TYPE)
  2356.         
  2357.         'Response.Write("<TD class='TasksTableCell'>")
  2358.         Response.Write("<TD class='TasksTableCell' "+_
  2359.                         taskHoverText +_
  2360.                         " onMouseOver=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(1)+"); OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2361.                         " onMouseOut=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(0)+"); OTS_OnShowTaskDescription(''); return true;"" "+_
  2362.                         " onclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "+Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2363.  
  2364.         '
  2365.         ' Output a task row
  2366.         '
  2367.  
  2368.         '
  2369.         ' IExplorer properly supports onclick event in SPAN's (HTML 4.0)
  2370.         '
  2371.         'If (OTS_IsExplorer() ) Then
  2372.             Response.Write("<DIV class=TasksTextDisabled ID='OTSTask"+CStr(rowCount)+"'"+_
  2373.                         " onMouseOver=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(1)+"); OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2374.                         " onMouseOut=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(0)+"); OTS_OnShowTaskDescription(''); return true;"" "+_
  2375.                         " xxonclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "+Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2376.             
  2377.             'Response.Write("<TD class='TasksTableCell'>")
  2378.             
  2379.             'Response.Write("  ")
  2380.             Response.Write(Server.HTMLEncode(taskName))
  2381.             
  2382.             'Response.Write("</TD>")
  2383.             Response.Write("</DIV>")
  2384.         '
  2385.         ' Navigator is not compliant with HTML 4.0, work around uses hyperlink
  2386.         '
  2387.         'Else
  2388.         '    Response.Write("<A class='TasksText' href='#' "+_
  2389.         '                " onMouseOver=""OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2390.         '                " onMouseOut=""OTS_OnShowTaskDescription(''); return true;"" "+_
  2391.         '                " onclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "++Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2392.         '    Response.Write(Server.HTMLEncode(taskName))
  2393.         '    Response.Write("</a>")
  2394.         'End If
  2395.         
  2396.         Response.Write("</TD>")
  2397.         Response.Write("</TR>"+vbCrLf)
  2398.     Next
  2399.  
  2400.     Response.Write("<TR height='100%'><TD> </TD></TR></TABLE>"+vbCrLf)
  2401.  
  2402.  
  2403.     OTS_RenderTasks = rc
  2404. End Function
  2405.  
  2406.  
  2407. Private Function OTS_OutputTasksScript(ByRef Table)
  2408.     Dim rc
  2409.     DIM tasks
  2410.     DIM task
  2411.     DIM rowCount
  2412.     DIM maxRows
  2413.     DIM taskFunction
  2414.     
  2415.     rc = gc_ERR_SUCCESS
  2416.     
  2417.     '
  2418.     ' Validate the table
  2419.     '
  2420.     If (NOT OTS_IsValidTable(Table)) Then
  2421.         OTS_OutputTasksScript = SA_SetLastError(OTS_ERR_INVALID_TABLE,_
  2422.                                 "OTS_OutputTasksScript")
  2423.         Exit Function
  2424.     End If
  2425.  
  2426.     '
  2427.     ' Get tasks data
  2428.     '
  2429.     rc = OTS_GetTableTasks(Table, tasks)
  2430.     If (rc <> gc_ERR_SUCCESS) Then
  2431.     
  2432.             Response.Write("<script language='JavaScript'>"+vbCrLf)
  2433.             Response.Write("//"+vbCrLf)
  2434.             Response.Write("// Task Objects"+vbCrLf)
  2435.             Response.Write("//"+vbCrLf)
  2436.             Response.Write("var aTasks = new Array();"+vbCrLf)
  2437.             Response.Write("</script>"+vbCrLf)
  2438.         
  2439.         OTS_OutputTasksScript = rc
  2440.         Exit Function
  2441.     End If
  2442.  
  2443.     '
  2444.     ' Write task table
  2445.     '
  2446.     maxRows = UBound(tasks)
  2447.     Response.Write("<script language='JavaScript'>"+vbCrLf)
  2448.     Response.Write("//"+vbCrLf)
  2449.     Response.Write("// Task Objects"+vbCrLf)
  2450.     Response.Write("//"+vbCrLf)
  2451.     Response.Write("var aTasks = new Array();"+vbCrLf)
  2452.     For rowCount = 0 to (maxRows-1)
  2453.         task = tasks(rowCount)
  2454.         taskFunction = task(OTS_TASK_FUNCTION)
  2455.         Response.Write("aTasks["+CStr(rowCount)+"] = new OTS_TaskObject('"+taskFunction+"');"+vbCrLf)
  2456.     Next
  2457.     Response.Write("</script>"+vbCrLf)
  2458.  
  2459.  
  2460.     OTS_OutputTasksScript = rc
  2461. End Function
  2462.  
  2463.  
  2464.  
  2465. Public Function Quote(s)
  2466.     Quote = "'"+s+"'"
  2467. End Function
  2468.  
  2469. ' --------------------------------------------------------------
  2470. ' Function:    Max
  2471. '
  2472. ' Synopsis:    Calculate the maximum between two values
  2473. ' --------------------------------------------------------------
  2474. Private Function Max(ByVal op1, ByVal op2)
  2475.     If ( op1 > op2 ) Then
  2476.         Max = op1
  2477.     Else
  2478.         Max = op2
  2479.     End If
  2480. End Function
  2481.  
  2482.  
  2483. Function OTS_IsExplorer()
  2484.     
  2485.     If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") Then
  2486.         OTS_IsExplorer = true
  2487.     Else
  2488.         OTS_IsExplorer = false
  2489.     End If
  2490. End Function
  2491.  
  2492.  
  2493. Private Function OTS_EmitAutoInitJavascript(ByRef table)
  2494.         
  2495.     Response.Write("<script>"+vbCrLf)
  2496.     Response.Write("    function Init()"+vbCrLf)
  2497.     Response.Write("    {"+vbCrLf)
  2498.     If ( OTS_IsTableMultiSelection( table ) ) Then
  2499.         Response.Write("    // Multiselection OTS items not automatically reselected"+vbCrLf)
  2500.         Response.Write("        // "+vbCrLf)
  2501.         Response.Write("        OTS_Init('');"+vbCrLf)
  2502.     Else
  2503.         Dim sPKeyParamName
  2504.         Call OTS_GetTablePKeyName(table, sPKeyParamName)
  2505.         Response.Write("        // "+vbCrLf)
  2506.         Response.Write("        // Autoselect OTS item"+vbCrLf)
  2507.         Response.Write("        // "+vbCrLf)
  2508.         Response.Write("        OTS_Init('"+Request.QueryString(sPKeyParamName)+"');"+vbCrLf)
  2509.     
  2510.     End If
  2511.     Response.Write("    }"+vbCrLf)
  2512.     Response.Write("</script>"+vbCrLf)
  2513.     
  2514. End Function
  2515.  
  2516.  
  2517. %>
  2518.